package ch.janotta.slawo.ultraquest.generators;

import ch.janotta.slawo.ultraquest.rulesets.SpeciesRulesetsFactory;
import ch.janotta.slawo.ultraquest.rulesets.SpeciesRuleset;
import ch.janotta.slawo.ultraquest.types.Character;
import ch.janotta.slawo.ultraquest.types.Gender;
import ch.janotta.slawo.ultraquest.types.Species;
import ch.janotta.slawo.ultraquest.utilities.Dice;

public class CharacterGenerator {
  public static Character generate(Species species) {
    SpeciesRuleset ruleset = SpeciesRulesetsFactory.getRulesetInstance(species);
    Character c = new Character();
    c.setSpecies(species);
    c.setGender(createRandomGender());
    c.setNativeAreas(ruleset.getInitialNativeAreas());
    c.setSpeed(ruleset.getInitialSpeed());
    c.setStrength(ruleset.getInitialStrength());
    c.setDexterity(ruleset.getInitialDexterity());
    c.setIntelligence(ruleset.getInitialIntelligence());
    c.setGold(Dice.getND6PlusM(10, 0)) ;
    return c;
  }

  private static Gender createRandomGender() {
    if (Dice.getRandomNumber(2) > 1) {
      return Gender.MALE;
    } else {
      return Gender.FEMALE;
    }
  }
}
